class Dictionary
{
    private _keys: Array<any> = new Array<any>();
    private _values: Array<any> = new Array<any>();

    constructor(init: { key: any; value: any; }[] = null)
    {
        if (init) 
        {
            for (var x = 0; x < init.length; x++) 
            {
                this._keys.push(init[x].key);
                this._values.push(init[x].value);
            }
        }
    }

    add(key: any, value: any)
    {
        var index = this._keys.indexOf(key);
        if (index != -1) {
            this._values[index] = value;
        } else {
            this._keys.push(key);
            this._values.push(value);
        }
    }

    remove(key: any)
    {
        var index = this._keys.indexOf(key);
        if (index != -1) 
        {
            this._keys.splice(index, 1);
            this._values.splice(index, 1);
        } 
        else 
        {
            console.error(key + " The Key not in Dictionary");
        }
    }

    getValue(key: any): any
    {
        var index = this._keys.indexOf(key);
        if (index != -1) 
        {
            return this._values[index];
        } 
        else 
        {
            console.error("Get:" + key + " The Key not in Dictionary");
        }
        return null;
    }

    get keys(): any[]
    {
        return this._keys;
    }

    get values(): any[]
    {
        return this._values;
    }

    containsKey(key: any)
    {
        if (this._keys.indexOf(key) == -1)
        {
            return false;
        }

        return true;
    }

    get count(): number
    {
        return this._keys.length;
    }

    clear(): void
    {
        this._keys.length = 0;
        this._values.length = 0;
    }

}